#include <iostream>
using namespace std;
class Complex {
private:
	int a;
	int b;
	//当成员变量是私有是 定义友元函数
	friend Complex& operator+(Complex& c1, Complex& c2);
	friend Complex& operator++(Complex& c1);
	friend Complex operator++(Complex& c1, int);
	
public:
	
	Complex(int a = 0, int b = 0) {
		this->a = a;
		this->b = b;
	}
	void printCom() {
		cout << a << "+" << b << "i" << endl;
	}
public:
	Complex operator- (Complex &c2) {
		Complex tmp(this->a - c2.a, this->b - c2.b);
		return tmp;
	}
	Complex& operator--() {
		this->a--;
		this->b--;
		return *this;
	}
	Complex operator--(int) {
		Complex tmp = *this;
		this->a--;
		this->b--;
		return tmp;
	}
};
Complex& operator+(Complex& c1, Complex& c2) {
	Complex tmp(c1.a + c2.a, c1.b + c2.b);
	return tmp;
};
Complex& operator++(Complex& c1) {
	c1.a++;
	c1.b++;
	return c1; 
}
Complex operator++(Complex& c1,int) {
	Complex tmp = c1;
	c1.a++;
	c1.b++;
	return tmp;
}

void main02() {
	Complex c1(1, 2), c2(3, 4);
	Complex c3 = c1 - c2;
	//c3.printCom();
	++c1;
	c1.printCom();
	--c1;
	c1.printCom();

	Complex tmp=c1++;
	tmp.printCom();
	c1.printCom();
	Complex tem2 = c1--;
	tem2.printCom();
	c1.printCom();
	
	system("pause");
}